Adding extra_hosts to the compose file stubs for automatic host.docker.internal mapping #222
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fantastic implementation of xdebug 3.0 by
Nick Haynes
in PR [#209], I think it's very pertinent to have the option of a step debugger built into the container.However, in the PR description, which has even been approved and merged,
Nick Haynes
cites the issue thathost.docker.internal
is not available in containers running in linux environments, and the fact that users of this OS have to update the environment variable in their projects using the command below:However, I would like to make a small contribution, which I believe is valid, as it will bring greater compatibility between Windows, Mac and Linux environments, so that we do not need extra commands to detect the IP of the
Host
machine.The version used in the template (docker-compose.stub) of sail already supports the addition of hostname mappings, with this we were able to solve the
host.docker.internal
issue no longer needing the use of extra commands to detect the IP address of the host machine. For this we can add the optionextra_hosts
to the service where we create the application container, so we will be adding a mapping forhost.docker.internal
pointing to the host machine.More information about the
extra_hosts
option can be found in the documentation at compose-file#extra_hostsA small change that would have value. The
laravel.test
service would look like this:With this, every time we create/start the application container the
host.docker.internal
mapping will be created and will point to the host machine. Inside the container in your/etc/hosts
file, the appropriate appointment records will be created, as shown in the example below: